package com.example.jnet.network;

import com.example.jnet.config.AppContext;
import com.example.jnet.pojo.MessageProtocol;
import com.example.jnet.services.ServiceManager;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class DispatchHandler extends SimpleChannelInboundHandler<MessageProtocol> {
    private static Logger logger = LoggerFactory.getLogger(DispatchHandler.class);

    @Override
    protected void channelRead0(ChannelHandlerContext channelHandlerContext, MessageProtocol messageProtocol) throws Exception {
        ServiceManager messageHandlerM = AppContext.getAppContext().getBean(ServiceManager.class);
        messageHandlerM.dispatcherMsg(channelHandlerContext, messageProtocol);
    }
}
